package com.ln.dm1102.demo03;


import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author Ln
 * @version 终极版
 * @date 2022/11/2 15:59
 */
public class Alibaba {

    public static void main(String[] args) {
//      int corePoolSize, 核心线程的个数
//      int maximumPoolSize, 最大线程的个数
//      long keepAliveTime, 线程对象空闲的时间
//      TimeUnit unit, 空闲时间单位
//      BlockingQueue<Runnable> workQueue：等待队列
        ThreadPoolExecutor threadPoolExecutor=new ThreadPoolExecutor(3,5,
                2000, TimeUnit.SECONDS,new LinkedBlockingQueue<>(3));

        for (int i = 0; i < 8; i++) {
            final int a=i;
            threadPoolExecutor.submit(new Runnable() {
                @Override
                public void run() {
                    System.out.println(Thread.currentThread().getName()+"===="+a);
                }
            });
        }
    }
}
